#include "mmxmemory.h"
void mmx_memcpy(void* dst, void* src, int len)
{
 _asm
 {
  push esi
  push edi
  push edx
  mov esi, [src] ; source array
  mov edi, [dst] ; destination array
  mov ecx, [len] ; number of QWORDS (8 bytes) assumes len / CACHEBLOCK is an integer
  shr ecx, 6
  mov edx, 0
  nop;lea esi, [esi+ecx*8] ; end of source
  nop;lea edi, [edi+ecx*8] ; end of destination
  neg ecx ; use a negative offset as a combo pointer-and-loop-counter
  
copyloop:
  movq mm0, [esi+edx*8]
  movq mm1, [esi+edx*8+8]
  movq mm2, [esi+edx*8+16]
  movq mm3, [esi+edx*8+24]
  movq mm4, [esi+edx*8+32]
  movq mm5, [esi+edx*8+40]
  movq mm6, [esi+edx*8+48]
  movq mm7, [esi+edx*8+56]
  movq [edi+edx*8], mm0
  movq [edi+edx*8+8], mm1
  movq [edi+edx*8+16], mm2
  movq [edi+edx*8+24], mm3
  movq [edi+edx*8+32], mm4
  movq [edi+edx*8+40], mm5
  movq [edi+edx*8+48], mm6
  movq [edi+edx*8+56], mm7
  add edx, 8
  add ecx, 1
  jnz copyloop
  emms
 
  pop edx
  pop edi
  pop esi
 }
}